<template>
  <el-dropdown style="margin-top:12px">
    <span class="el-dropdown-link">{{$t('language')}}</span>
    <el-icon class="el-icon--right">
      <arrow-down />
    </el-icon>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item @click="changeLang(item,ind)" v-for="(item,ind) in arr" :disabled="active==ind" :key="ind">{{item.name}}</el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script>
import { ArrowDown, Loading } from '@element-plus/icons-vue';
export default {
  data(){
    return {
      active:0,
      arr:[{name:'中文',lang:'zh'},{name:'English',lang:'en'}]
    }
  },
  methods: {
    changeLang(item,ind) {
      this.active = ind
      this.$i18n.locale = item.lang
      localStorage.setItem("lang", item.lang)
    }
  },
  components:{
      ArrowDown
  }
}
</script>

<style lang="less" scoped>
.el-icon--right{
  vertical-align: middle;
}
.el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
}
</style>